#include "NetworkTools.h"

std::pair<cv::Mat, cv::Size> NetworkTool::ToolImagepreprocess(QString imageSrc){
    cv::Mat oriImage = cv::imread(imageSrc.toStdString());
    cv::Size oriSize = oriImage.size();

    /*
     self.transform = transforms.Compose([
          transforms.Resize((512, 512), Image.BICUBIC),
          transforms.ToTensor(),
          transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
      ])
    */
    cv::Mat tensorMat = cv::dnn::blobFromImage(oriImage, 1.0 / 255.0, cv::Size(512, 512),
                                               cv::Scalar(), true);
    tensorMat = (tensorMat - 0.5) / 0.5;
    return std::pair(tensorMat, oriSize);
}
